package com.first.statistics.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.first.common.pojo.TbMember;
import com.first.common.vo.Result;
import com.first.statistics.dao.TbMemberDao;
import com.first.statistics.service.TbMemberService;
import com.first.statistics.vo.IsTypeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: SecondProject
 * @description:
 * @author: 李榕轩
 * @create: 2023-05-29 17:20
 **/
@Service
public class TbMemberServiceImpl implements TbMemberService {
    @Autowired
    private TbMemberDao tbMemberDao;
    @Override
    public Result findByMember() {
        List<TbMember> members = tbMemberDao.selectList(null);
        long count = members.stream().filter(member -> member.getIsType() == 0).count();//拿到类型为0的个数
        long count1 = members.stream().filter(member -> member.getIsType() == 1).count(); // 1 的个数

        ArrayList<IsTypeVo> typelist = new ArrayList<>();
        typelist.add(new IsTypeVo("会员",count));
        typelist.add(new IsTypeVo("讲师",count1));
        return Result.success(typelist);
    }

}